home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / lang / SmallEiffel.lha / SmallEiffel / man / external.txt < prev    next >
Text File  |  1998-12-22  |  4KB  |  100 lines

  1.  
  2.                                  Externals
  3.                                       
  4.    Here is the information you need if you want to call C or Java code
  5.    from Eiffel code (to call Eiffel feature from C or Java see [1]cecil
  6.    file).
  7.    
  8.    The most common way to call external code from Eiffel is to use the
  9.    external feature definition as described in the book "Eiffel The
  10.    Language". See also the SmallEiffel directory "lib_show/external" to
  11.    have some examples.
  12.    
  13.    Below is the current list of SmallEiffel external specifications.
  14.    
  15.    external "C_WithoutCurrent"
  16.    
  17.    Simple call to a C function (or procedure). The external called
  18.    routine does not get Current. A C prototype is automatically added in
  19.    generated header C file.
  20.    Note: for compatibility with other Eiffel compilers external "C" is
  21.    treated exactly as external "C_WithoutCurrent".
  22.    
  23.    external "C_WithCurrent"
  24.    
  25.    C call with Current. The external called routine get Current as first
  26.    argument. A C prototype is automatically added in generated heading C
  27.    file.
  28.    
  29.    external "C_InlineWithoutCurrent"
  30.    
  31.    Inlined C call. As for "C_WithoutCurrent", the external called routine
  32.    does not get Current. No prototype produced in the header file.
  33.    
  34.    external "C_InlineWithCurrent"
  35.    
  36.    Inlined C call with Current. As for "C_WithCurrent", the called
  37.    routine get Current as a first argument. No prototype produced in the
  38.    header file.
  39.    
  40.    external "SmallEiffel"
  41.    
  42.    This external specification is reserved to the SmallEiffel compiler
  43.    itself. Do not use it. Such a feature is directly supported both by
  44.    compile_to_c and compile_to_jvm. For example, infix "+" of INTEGER is
  45.    direcly mapped as C '+' by compile_to_c. For the same infix "+",
  46.    command compile_to_jvm produce the appropriate Java virtual machine
  47.    byte code.
  48.    
  49.    external "JVM_invokestatic"
  50.    
  51.    Calling a Java static method. As it is a static Java call, the Eiffel
  52.    receiver is not used. The "alias" field of the feature is used to
  53.    indicate the Java class, the Java function name and the corresponding
  54.    Java bytecode descriptor. Syntax to use in the alias string is :
  55.    alias "<JavaClassPath>.<MethodName> <Descriptor>"
  56.           
  57.    A dot is the separator between <JavaClassPath> and <MethodName>.
  58.    A blank character is the separator between <MethodName> and
  59.    <Descriptor>.
  60.    The <JavaClassPath> uses the JVM internal notation as described in
  61.    JVMS(*). For example, when one wants to use java.lang.Math, the
  62.    <JavaClassPath> is "java/lang/Math". The <MethodName> gives the Java
  63.    method name. The <Descriptor> gives the internal Java bytecode
  64.    descriptor as described in JVMS(*).
  65. (*) - JVMS -
  66.    "The Java Virtual Machine Specification",
  67.    Tim Lindholm and Frank Yellin, The Java Series,
  68.    Addison-Wesley, ISBN 0-201-63452-X.
  69.  
  70.    external "JVM_invokevirtual"
  71.    
  72.    Calling a Java virtual method. As for "JVM_invokestatic", the alias
  73.    string gives all needed information to call the virtual function. The
  74.    Current Eiffel target is not used (only arguments and the result are
  75.    considered).
  76.    
  77.    Inlining C code
  78.    
  79.    Another way to call C code from Eiffel is to use "c_inline_c" or
  80.    "c_inline_h" as defined in GENERAL. The argument of "c_inline_c" (or
  81.    "c_inline_h") must always be a manifest string which may contains the
  82.    C code you want to put inlieu.
  83.    Using c_inline_[c/h] also implies you do know exactly the C code
  84.    SmallEiffel produces. For portability, it is also much better to use
  85.    previous solutions.
  86.    People who tinker with the C code generated by SmallEiffel, not
  87.    limiting themselves to the Cecil and/or external interfaces, should
  88.    also read [2]this page about the C code generated by SmallEiffel,
  89.    Otherwise they might get into trouble.
  90.    
  91.                                    [Line]
  92.    Copyright © Dominique COLNET and Suzanne COLLIN - [3]<colnet@loria.fr>
  93.               Last update: Sunday December 6th, 1998, by OZ. 
  94.  
  95. References
  96.  
  97.    1. file://localhost/home/colnet/SmallEiffel/man/man/cecil.html
  98.    2. file://localhost/home/colnet/SmallEiffel/man/man/c_code.html
  99.    3. mailto:colnet@loria.fr
  100.